<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="${ctxStatic }/zepto/zepto.min.js"></script>
<script src="${ctxStatic }/mui/js/mui.min.js"></script>
<c:if test="${not empty include_location}">
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.3&key=21298d90aa36cffdcef53cae577ae45d&plugin=AMap.CitySearch"></script>
</c:if>
<script>
	function page(n,s){
		var url = window.location.href;
		url = changeURLArg(url,'pageNo',n);
		url = changeURLArg(url,'pageSize',s);
		window.location.href = url;
	}
	function changeURLArg(url,arg,arg_val){ 
	    var pattern=arg+'=([^&]*)'; 
	    var replaceText=arg+'='+arg_val; 
	    if(url.match(pattern)){ 
	        var tmp='/('+ arg+'=)([^&]*)/gi'; 
	        tmp=url.replace(eval(tmp),replaceText); 
	        return tmp; 
	    }else{ 
	        if(url.match('[\?]')){ 
	            return url+'&'+replaceText; 
	        }else{ 
	            return url+'?'+replaceText; 
	        } 
	    } 
	    return url+'\n'+arg+'\n'+arg_val; 
	} 
	mui.init({
		swipeBack : true
	});
	//<c:if test="${not empty message and empty messageFix}">
	mui.alert('${message}', '提示'
	//<c:if test="${not empty include_history}">
	, function() {
		history.go(-1);
	} // </c:if>
	);// </c:if>

	$(function() {
		//<c:if test="${not empty include_location}">
		showCityInfo();//</c:if>
		// <c:if test="${not empty include_menu}">菜单跳转
		$('.mui-tab-item').on('tap', function() {
			if ($(this).attr('data-url') != '') {
				window.location.href = $(this).attr('data-url');
			}
		}); // </c:if>
		$('ul.mui-pager li a').on('tap',function(){
			var ts = $(this);
			var pageNo = $(this).attr('data-pageno');
			var pageSize = $(this).attr('data-pagesize');
			if(pageNo && pageSize) {
				page(pageNo, pageSize);
			}
		});
	});
	//获取用户所在城市信息
	function showCityInfo() {
		//实例化城市查询类
		var citysearch = new AMap.CitySearch();
		//自动获取用户IP，返回当前城市
		citysearch.getLocalCity(function(status, result) {
			var cityinfo = '';
			if (status === 'complete' && result.info === 'OK') {
				if (result && result.city) {
					cityinfo = result.city;
				}
			} else {
				cityinfo = '常州市';
			}
			$.post('${ctxFront}/json/getSiteidByName', {
				name : cityinfo
			}, function(data) {
				// 定位城市选中
				$('input[data-autocity="yes"]').val(data.siteid);
				$('input[data-autocity-name="yes"]').val(data.sitename);
			});
		});
	}
</script>